"""
Alpha101因子配置
===============

包含所有101个Alpha因子的配置信息，包括公式、依赖项、参数等。
"""

# Alpha101因子配置字典
ALPHA_CONFIG = {
    "alpha001": {
        "formula": "rank(ts_argmax(power(((returns < 0) ? stddev(returns, 20) : close), 2.), 5)) - 0.5",
        "dependencies": ["close", "returns"],
        "window": 20,
        "description": "基于收益率波动的排序因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha002": {
        "formula": "(-1 * correlation(rank(delta(log(volume), 2)), rank(((close - open) / open)), 6))",
        "dependencies": ["volume", "close", "open"],
        "window": 6,
        "description": "成交量与价格变化的负相关因子",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha003": {
        "formula": "(-1 * correlation(rank(open), rank(volume), 10))",
        "dependencies": ["open", "volume"],
        "window": 10,
        "description": "开盘价与成交量的负相关因子",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha004": {
        "formula": "(-1 * ts_rank(rank(low), 9))",
        "dependencies": ["low"],
        "window": 9,
        "description": "最低价排名的时间序列排序",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha005": {
        "formula": "rank((open - (sum(vwap, 10) / 10))) * (-1 * abs(rank((close - vwap))))",
        "dependencies": ["open", "vwap", "close"],
        "window": 10,
        "description": "开盘价与VWAP偏离度的复合因子",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha006": {
        "formula": "(-1 * correlation(open, volume, 10))",
        "dependencies": ["open", "volume"],
        "window": 10,
        "description": "开盘价与成交量的负相关",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha007": {
        "formula": "((adv20 < volume) ? ((-1 * ts_rank(abs(delta(close, 7)), 60)) * sign(delta(close, 7))) : (-1))",
        "dependencies": ["volume", "close", "adv20"],
        "window": 60,
        "description": "基于成交量条件的价格动量因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha008": {
        "formula": "(-1 * rank(((sum(open, 5) * sum(returns, 5)) - delay((sum(open, 5) * sum(returns, 5)), 10))))",
        "dependencies": ["open", "returns"],
        "window": 15,
        "description": "开盘价与收益率乘积的延迟差异",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha009": {
        "formula": "((0 < ts_min(delta(close, 1), 5)) ? delta(close, 1) : ((ts_max(delta(close, 1), 5) < 0) ? delta(close, 1) : (-1 * delta(close, 1))))",
        "dependencies": ["close"],
        "window": 5,
        "description": "基于价格变化方向的条件因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha010": {
        "formula": "rank(((0 < ts_min(delta(close, 1), 4)) ? delta(close, 1) : ((ts_max(delta(close, 1), 4) < 0) ? delta(close, 1) : (-1 * delta(close, 1)))))",
        "dependencies": ["close"],
        "window": 4,
        "description": "价格变化方向的排序因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha011": {
        "formula": "((rank(ts_max((vwap - close), 3)) + rank(ts_min((vwap - close), 3))) * rank(delta(volume, 3)))",
        "dependencies": ["vwap", "close", "volume"],
        "window": 3,
        "description": "VWAP与收盘价偏离度结合成交量变化",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha012": {
        "formula": "(sign(delta(volume, 1)) * (-1 * delta(close, 1)))",
        "dependencies": ["volume", "close"],
        "window": 1,
        "description": "成交量变化符号与价格变化的反向关系",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha013": {
        "formula": "(-1 * rank(covariance(rank(close), rank(volume), 5)))",
        "dependencies": ["close", "volume"],
        "window": 5,
        "description": "收盘价与成交量排名的协方差",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha014": {
        "formula": "((-1 * rank(delta(returns, 3))) * correlation(open, volume, 10))",
        "dependencies": ["returns", "open", "volume"],
        "window": 10,
        "description": "收益率变化与开盘价成交量相关性的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha015": {
        "formula": "(-1 * sum(rank(correlation(rank(high), rank(volume), 3)), 3))",
        "dependencies": ["high", "volume"],
        "window": 6,
        "description": "最高价与成交量相关性的累积排名",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha016": {
        "formula": "(-1 * rank(covariance(rank(high), rank(volume), 5)))",
        "dependencies": ["high", "volume"],
        "window": 5,
        "description": "最高价与成交量排名的协方差",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha017": {
        "formula": "(((-1 * rank(ts_rank(close, 10))) * rank(delta(delta(close, 1), 1))) * rank(ts_rank((volume / adv20), 5)))",
        "dependencies": ["close", "volume", "adv20"],
        "window": 10,
        "description": "价格时序排名与成交量相对强度的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha018": {
        "formula": "(-1 * rank(((stddev(abs((close - open)), 5) + (close - open)) + correlation(close, open, 10))))",
        "dependencies": ["close", "open"],
        "window": 10,
        "description": "价格波动与开收盘价相关性的综合",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha019": {
        "formula": "((-1 * sign(((close - delay(close, 7)) + delta(close, 7)))) * (1 + rank((1 + sum(returns, 250)))))",
        "dependencies": ["close", "returns"],
        "window": 250,
        "description": "价格变化符号与长期收益率的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha020": {
        "formula": "(((-1 * rank((open - delay(high, 1)))) * rank((open - delay(close, 1)))) * rank((open - delay(low, 1))))",
        "dependencies": ["open", "high", "close", "low"],
        "window": 1,
        "description": "开盘价与前日价格关系的复合排名",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha021": {
        "formula": "((((sum(close, 8) / 8) + stddev(close, 8)) < (sum(close, 2) / 2)) ? (-1) : (((sum(close, 2) / 2) < ((sum(close, 8) / 8) - stddev(close, 8))) ? 1 : (((1 < (volume / adv20)) || ((volume / adv20) == 1)) ? 1 : (-1))))",
        "dependencies": ["close", "volume", "adv20"],
        "window": 8,
        "description": "基于价格均值和波动率的条件因子",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha022": {
        "formula": "(-1 * (delta(correlation(high, volume, 5), 5) * rank(stddev(close, 20))))",
        "dependencies": ["high", "volume", "close"],
        "window": 20,
        "description": "最高价成交量相关性变化与价格波动的复合",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha023": {
        "formula": "(((sum(high, 20) / 20) < high) ? (-1 * delta(high, 2)) : 0)",
        "dependencies": ["high"],
        "window": 20,
        "description": "基于最高价均值的条件动量因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha024": {
        "formula": "((((delta((sum(close, 100) / 100), 100) / delay(close, 100)) < 0.05) || ((delta((sum(close, 100) / 100), 100) / delay(close, 100)) == 0.05)) ? (-1 * (close - ts_min(close, 100))) : (-1 * delta(close, 3)))",
        "dependencies": ["close"],
        "window": 100,
        "description": "基于长期价格趋势的条件因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha025": {
        "formula": "rank(((((-1 * returns) * adv20) * vwap) * (high - close)))",
        "dependencies": ["returns", "adv20", "vwap", "high", "close"],
        "window": 20,
        "description": "收益率、成交量、价格的综合排名因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha026": {
        "formula": "(-1 * ts_max(correlation(ts_rank(volume, 5), ts_rank(high, 5), 5), 3))",
        "dependencies": ["volume", "high"],
        "window": 5,
        "description": "成交量与最高价时序排名相关性的最大值",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha027": {
        "formula": "((0.5 < rank((sum(correlation(rank(volume), rank(vwap), 6), 2) / 2.0))) ? (-1) : 1)",
        "dependencies": ["volume", "vwap"],
        "window": 6,
        "description": "基于成交量与VWAP相关性的条件因子",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha028": {
        "formula": "scale(((correlation(adv20, low, 5) + ((high + low) / 2)) - close))",
        "dependencies": ["adv20", "low", "high", "close"],
        "window": 5,
        "description": "平均成交量与最低价相关性结合价格中位数",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha029": {
        "formula": "(min(product(rank(rank(scale(log(sum(ts_min(rank(rank((-1 * rank(delta(close, 5))))), 2), 1))))), 1), 5) + ts_rank(delay((-1 * returns), 6), 5))",
        "dependencies": ["close", "returns"],
        "window": 6,
        "description": "复杂的价格变化与延迟收益率的组合因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha030": {
        "formula": "(((1.0 - rank(((sign((close - delay(close, 1))) + sign((delay(close, 1) - delay(close, 2)))) + sign((delay(close, 2) - delay(close, 3)))))) * sum(volume, 5)) / sum(volume, 20))",
        "dependencies": ["close", "volume"],
        "window": 20,
        "description": "基于价格变化符号的成交量加权因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha031": {
        "formula": "((rank(rank(rank(decay_linear((-1 * rank(rank(delta(close, 10)))), 10)))) + rank((-1 * delta(close, 3)))) + sign(scale(correlation(adv20, low, 12))))",
        "dependencies": ["close", "adv20", "low"],
        "window": 12,
        "description": "线性衰减价格变化与成交量低价相关性的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha032": {
        "formula": "(scale(((sum(close, 7) / 7) - close)) + (20 * scale(correlation(vwap, delay(close, 5), 230))))",
        "dependencies": ["close", "vwap"],
        "window": 230,
        "description": "价格均值偏离与VWAP延迟相关性的组合",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha033": {
        "formula": "rank((-1 * ((1 - (open / close))^1)))",
        "dependencies": ["open", "close"],
        "window": 1,
        "description": "开收盘价比率的排名因子",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha034": {
        "formula": "rank(((1 - rank((stddev(returns, 2) / stddev(returns, 5)))) + (1 - rank(delta(close, 1)))))",
        "dependencies": ["returns", "close"],
        "window": 5,
        "description": "收益率波动率比率与价格变化的复合排名",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha035": {
        "formula": "((ts_rank(volume, 32) * (1 - ts_rank(((close + high) - low), 16))) * (1 - ts_rank(returns, 32)))",
        "dependencies": ["volume", "close", "high", "low", "returns"],
        "window": 32,
        "description": "成交量、价格范围和收益率的时序排名组合",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha036": {
        "formula": "(((((2.21 * rank(correlation(close, volume, 15))) + (0.7 * rank((open - close)))) + (0.73 * rank(ts_rank(delay((-1 * returns), 6), 5)))) + rank(abs(correlation(vwap, adv20, 6)))) + (0.6 * rank((((sum(close, 200) / 200) - open) * (close - open)))))",
        "dependencies": ["close", "volume", "open", "returns", "vwap", "adv20"],
        "window": 200,
        "description": "多因子加权组合的复杂因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha037": {
        "formula": "(rank(correlation(delay((open - close), 1), close, 200)) + rank((open - close)))",
        "dependencies": ["open", "close"],
        "window": 200,
        "description": "延迟开收盘价差与收盘价相关性的排名",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha038": {
        "formula": "((-1 * rank(ts_rank(close, 10))) * rank((close / open)))",
        "dependencies": ["close", "open"],
        "window": 10,
        "description": "收盘价时序排名与开收盘价比率的复合",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha039": {
        "formula": "((-1 * rank((delta(close, 7) * (1 - rank(decay_linear((volume / adv20), 9)))))) * (1 + rank(sum(returns, 250))))",
        "dependencies": ["close", "volume", "adv20", "returns"],
        "window": 250,
        "description": "价格变化与成交量衰减及长期收益率的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha040": {
        "formula": "((-1 * rank(stddev(high, 10))) * correlation(high, volume, 10))",
        "dependencies": ["high", "volume"],
        "window": 10,
        "description": "最高价波动率与成交量相关性的复合",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha041": {
        "formula": "(((high * low)^0.5) - vwap)",
        "dependencies": ["high", "low", "vwap"],
        "window": 1,
        "description": "最高最低价几何平均与VWAP的差值",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha042": {
        "formula": "(rank((vwap - close)) / rank((vwap + close)))",
        "dependencies": ["vwap", "close"],
        "window": 1,
        "description": "VWAP与收盘价差值与和值的排名比率",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha043": {
        "formula": "(ts_rank((volume / adv20), 20) * ts_rank((-1 * delta(close, 7)), 8))",
        "dependencies": ["volume", "adv20", "close"],
        "window": 20,
        "description": "成交量相对强度与价格变化的时序排名乘积",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha044": {
        "formula": "(-1 * correlation(high, rank(volume), 5))",
        "dependencies": ["high", "volume"],
        "window": 5,
        "description": "最高价与成交量排名的负相关",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha045": {
        "formula": "(-1 * ((rank((sum(delay(close, 5), 20) / 20)) * correlation(close, volume, 2)) * rank(correlation(sum(close, 5), sum(close, 20), 2))))",
        "dependencies": ["close", "volume"],
        "window": 20,
        "description": "延迟价格均值与价格成交量相关性的复合",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha046": {
        "formula": "((0.25 < (((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10))) ? (-1) : (((((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10)) < 0) ? 1 : ((-1 * (close - delay(close, 1))))))",
        "dependencies": ["close"],
        "window": 20,
        "description": "基于价格趋势变化的条件因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha047": {
        "formula": "((((rank((1 / close)) * volume) / adv20) * ((high * rank((high - close))) / (sum(high, 5) / 5)))",
        "dependencies": ["close", "volume", "adv20", "high"],
        "window": 5,
        "description": "价格倒数与成交量及最高价的复合因子",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha048": {
        "formula": "(indneutralize(((correlation(delta(close, 1), delta(delay(close, 1), 1), 250) * delta(close, 1)) / close), IndClass.subindustry) / sum(((delta(close, 1) / delay(close, 1))^2), 250))",
        "dependencies": ["close"],
        "window": 250,
        "description": "行业中性化的价格变化相关性因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha049": {
        "formula": "(((((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10)) < (-1 * 0.1)) ? 1 : ((-1 * (close - delay(close, 1)))))",
        "dependencies": ["close"],
        "window": 20,
        "description": "基于价格趋势加速度的条件因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha050": {
        "formula": "(-1 * ts_max(rank(correlation(rank(volume), rank(vwap), 5)), 5))",
        "dependencies": ["volume", "vwap"],
        "window": 5,
        "description": "成交量与VWAP排名相关性的最大值",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha051": {
        "formula": "(((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10))",
        "dependencies": ["close"],
        "window": 20,
        "description": "价格趋势加速度因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha052": {
        "formula": "((((-1 * ts_min(low, 5)) + delay(ts_min(low, 5), 5)) * rank(((sum(returns, 240) - sum(returns, 20)) / 220))) * ts_rank(volume, 5))",
        "dependencies": ["low", "returns", "volume"],
        "window": 240,
        "description": "最低价与长期收益率及成交量的复合因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha053": {
        "formula": "(-1 * delta(((close - low) / (high - low)), 9))",
        "dependencies": ["close", "high", "low"],
        "window": 9,
        "description": "价格在日内区间位置的变化",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha054": {
        "formula": "((-1 * ((low - close) * (open^5))) / ((low - high) * (close^5)))",
        "dependencies": ["low", "close", "open", "high"],
        "window": 1,
        "description": "基于价格关系的非线性因子",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha055": {
        "formula": "(-1 * correlation(rank(((close - ts_min(low, 12)) / (ts_max(high, 12) - ts_min(low, 12)))), rank(volume), 6))",
        "dependencies": ["close", "high", "low", "volume"],
        "window": 12,
        "description": "标准化价格位置与成交量的负相关",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha056": {
        "formula": "(0 - (1 * (rank((sum(returns, 10) / sum(sum(returns, 2), 3))) * rank((returns * cap)))))",
        "dependencies": ["returns", "volume"],
        "window": 10,
        "description": "收益率比率与市值加权收益率的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha057": {
        "formula": "(0 - (1 * ((close - vwap) / decay_linear(rank(ts_argmax(close, 30)), 2))))",
        "dependencies": ["close", "vwap"],
        "window": 30,
        "description": "收盘价与VWAP偏离度的衰减加权因子",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha058": {
        "formula": "(-1 * ts_rank(decay_linear(correlation(IndNeutralize(vwap, IndClass.sector), volume, 3.92593), 7.89391), 5.50322))",
        "dependencies": ["vwap", "volume"],
        "window": 8,
        "description": "行业中性化VWAP与成交量相关性的时序排名",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha059": {
        "formula": "(-1 * ts_rank(decay_linear(correlation(IndNeutralize(((vwap * 0.728317) + (vwap * (1 - 0.728317))), IndClass.industry), volume, 4.25197), 16.2289), 8.19648))",
        "dependencies": ["vwap", "volume"],
        "window": 16,
        "description": "行业中性化加权VWAP与成交量相关性的衰减排名",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha060": {
        "formula": "(0 - (1 * ((2 * scale(rank(((((close - low) - (high - close)) / (high - low)) * volume)))) - scale(rank(ts_argmax(close, 10))))))",
        "dependencies": ["close", "high", "low", "volume"],
        "window": 10,
        "description": "价格动量与成交量加权及最高价位置的复合",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha061": {
        "formula": "(rank((vwap - ts_min(vwap, 16.1219))) < rank(correlation(vwap, adv180, 17.9282)))",
        "dependencies": ["vwap", "adv20"],
        "window": 18,
        "description": "VWAP相对位置与平均成交量相关性的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha062": {
        "formula": "((rank(correlation(vwap, sum(adv20, 22.4101), 9.91009)) < rank(((rank(open) + rank(open)) < (rank(((high + low) / 2)) + rank(high))))) * -1)",
        "dependencies": ["vwap", "adv20", "open", "high", "low"],
        "window": 22,
        "description": "VWAP与成交量相关性及价格排名关系的复合",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha063": {
        "formula": "((rank(decay_linear(delta(IndNeutralize(close, IndClass.industry), 2.25164), 8.22237)) - rank(decay_linear(correlation(((vwap * 0.318108) + (open * (1 - 0.318108))), sum(adv180, 37.2467), 13.557), 12.2883))) * -1)",
        "dependencies": ["close", "vwap", "open", "adv20"],
        "window": 37,
        "description": "行业中性化价格变化与加权价格成交量相关性的差值",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha064": {
        "formula": "((rank(correlation(sum(((open * 0.178404) + (low * (1 - 0.178404))), 12.7054), sum(adv120, 12.7054), 16.6208)) < rank(delta(((((high + low) / 2) * 0.178404) + (vwap * (1 - 0.178404))), 3.69741))) * -1)",
        "dependencies": ["open", "low", "high", "vwap", "adv20"],
        "window": 17,
        "description": "加权价格与成交量相关性及价格变化的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha065": {
        "formula": "((rank(correlation(((open * 0.00817205) + (vwap * (1 - 0.00817205))), sum(adv60, 8.6911), 6.40374)) < rank((open - ts_min(open, 13.635)))) * -1)",
        "dependencies": ["open", "vwap", "adv20"],
        "window": 14,
        "description": "微调权重价格与成交量相关性及开盘价位置的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha066": {
        "formula": "((rank(decay_linear(delta(vwap, 3.51013), 7.23052)) + ts_rank(decay_linear(((((low * 0.96633) + (low * (1 - 0.96633))) - vwap) / (open - ((high + low) / 2))), 11.4157), 6.72611)) * -1)",
        "dependencies": ["vwap", "low", "open", "high"],
        "window": 11,
        "description": "VWAP变化与价格比率的衰减加权组合",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha067": {
        "formula": "((rank((high - ts_min(high, 2.14593)))^rank(correlation(IndNeutralize(vwap, IndClass.sector), IndNeutralize(adv20, IndClass.sector), 6.02936))) * -1)",
        "dependencies": ["high", "vwap", "adv20"],
        "window": 6,
        "description": "最高价相对位置与行业中性化VWAP成交量相关性的幂运算",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha068": {
        "formula": "((ts_rank(correlation(rank(high), rank(adv15), 8.91644), 13.9333) < rank(delta(((close * 0.518371) + (low * (1 - 0.518371))), 1.06157))) * -1)",
        "dependencies": ["high", "close", "low", "adv20"],
        "window": 14,
        "description": "最高价与成交量相关性时序排名与加权价格变化的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha069": {
        "formula": "((rank(ts_max(delta(IndNeutralize(vwap, IndClass.industry), 2.72412), 4.79344))^ts_rank(correlation(((close * 0.490655) + (vwap * (1 - 0.490655))), adv20, 4.92416), 9.0615)) * -1)",
        "dependencies": ["vwap", "close", "adv20"],
        "window": 9,
        "description": "行业中性化VWAP变化最大值与加权价格成交量相关性的幂运算",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha070": {
        "formula": "((rank(delta(vwap, 1.29456))^ts_rank(correlation(IndNeutralize(close, IndClass.industry), adv50, 17.8256), 17.9171)) * -1)",
        "dependencies": ["vwap", "close", "adv20"],
        "window": 18,
        "description": "VWAP变化与行业中性化收盘价成交量相关性的幂运算",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha071": {
        "formula": "max(ts_rank(decay_linear(correlation(ts_rank(close, 3.43976), ts_rank(adv180, 12.0647), 18.0175), 4.20501), 15.6948), ts_rank(decay_linear((rank(((low + open) - (vwap + vwap)))^2), 16.4662), 4.4388))",
        "dependencies": ["close", "low", "open", "vwap", "adv20"],
        "window": 18,
        "description": "价格时序排名相关性与价格偏离度平方的最大值",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha072": {
        "formula": "(rank(decay_linear(correlation(((high + low) / 2), adv40, 8.93345), 10.1519)) / rank(decay_linear(correlation(ts_rank(vwap, 3.72469), ts_rank(volume, 18.5188), 6.86671), 2.95011)))",
        "dependencies": ["high", "low", "vwap", "volume", "adv20"],
        "window": 19,
        "description": "中间价与成交量相关性除以VWAP成交量时序相关性",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha073": {
        "formula": "(max(rank(decay_linear(delta(vwap, 4.72775), 2.91864)), ts_rank(decay_linear(((delta(((open * 0.147155) + (low * (1 - 0.147155))), 2.03608) / ((open * 0.147155) + (low * (1 - 0.147155)))) * -1), 3.33829), 16.7411)) * -1)",
        "dependencies": ["vwap", "open", "low"],
        "window": 17,
        "description": "VWAP变化与加权价格变化率的最大值",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha074": {
        "formula": "((rank(correlation(close, sum(adv30, 37.4843), 15.1365)) < rank(correlation(rank(((high * 0.0261661) + (vwap * (1 - 0.0261661)))), rank(volume), 11.4791))) * -1)",
        "dependencies": ["close", "high", "vwap", "volume", "adv20"],
        "window": 37,
        "description": "收盘价与成交量相关性及加权价格与成交量排名相关性的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha075": {
        "formula": "(rank(correlation(vwap, volume, 4.24304)) < rank(correlation(rank(low), rank(adv50), 12.4413)))",
        "dependencies": ["vwap", "volume", "low", "adv20"],
        "window": 12,
        "description": "VWAP成交量相关性与最低价成交量排名相关性的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha076": {
        "formula": "(max(rank(decay_linear(delta(vwap, 1.24383), 11.8259)), ts_rank(decay_linear(ts_rank(correlation(IndNeutralize(low, IndClass.sector), adv81, 8.14941), 19.569), 17.1543), 19.383)) * -1)",
        "dependencies": ["vwap", "low", "adv20"],
        "window": 20,
        "description": "VWAP变化与行业中性化最低价成交量相关性的复合因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha077": {
        "formula": "min(rank(decay_linear(((((high + low) / 2) + high) - (vwap + high)), 20.0451)), rank(decay_linear(correlation(((high + low) / 2), adv40, 3.1614), 5.64125)))",
        "dependencies": ["high", "low", "vwap", "adv20"],
        "window": 20,
        "description": "价格偏离与中间价成交量相关性的最小值",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha078": {
        "formula": "(rank(correlation(sum(((low * 0.352233) + (vwap * (1 - 0.352233))), 19.7428), sum(adv40, 19.7428), 6.83313))^rank(correlation(rank(vwap), rank(volume), 5.77492)))",
        "dependencies": ["low", "vwap", "volume", "adv20"],
        "window": 20,
        "description": "加权价格与成交量相关性的幂运算因子",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha079": {
        "formula": "(rank(delta(IndNeutralize(((close * 0.60733) + (open * (1 - 0.60733))), IndClass.sector), 1.23438)) < rank(correlation(ts_rank(vwap, 3.60973), ts_rank(adv150, 9.18637), 14.6644)))",
        "dependencies": ["close", "open", "vwap", "adv20"],
        "window": 15,
        "description": "行业中性化加权价格变化与VWAP成交量时序相关性的比较",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha080": {
        "formula": "((rank(sign(delta(IndNeutralize(((open * 0.868128) + (high * (1 - 0.868128))), IndClass.industry), 4.04545)))^ts_rank(correlation(high, adv10, 5.11456), 5.53756)) * -1)",
        "dependencies": ["open", "high", "adv20"],
        "window": 6,
        "description": "行业中性化加权价格变化符号与最高价成交量相关性的幂运算",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha081": {
        "formula": "((rank(log(product(rank((rank(correlation(vwap, sum(adv10, 49.6054), 8.47743))^4)), 14.9655))) < rank(correlation(rank(vwap), rank(adv81), 5.07914))) * -1)",
        "dependencies": ["vwap", "adv20"],
        "window": 50,
        "description": "VWAP与成交量相关性的对数乘积与排名相关性的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha082": {
        "formula": "(min(rank(decay_linear(delta(open, 1.46063), 14.8717)), ts_rank(decay_linear(correlation(IndNeutralize(volume, IndClass.sector), ((open * 0.634196) + (open * (1 - 0.634196))), 17.4842), 6.92131), 13.4283)) * -1)",
        "dependencies": ["open", "volume"],
        "window": 17,
        "description": "开盘价变化与行业中性化成交量开盘价相关性的最小值",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha083": {
        "formula": "((rank(delay(((high - low) / (sum(close, 5) / 5)), 2)) * rank(rank(volume))) / (((high - low) / (sum(close, 5) / 5)) / (vwap - close)))",
        "dependencies": ["high", "low", "close", "volume", "vwap"],
        "window": 5,
        "description": "延迟价格范围比率与成交量排名的复合除法因子",
        "category": "volatility",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha084": {
        "formula": "SignedPower(ts_rank((vwap - ts_max(vwap, 15.3217)), 20.7127), delta(close, 4.96796))",
        "dependencies": ["vwap", "close"],
        "window": 21,
        "description": "VWAP相对位置的符号幂运算因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha085": {
        "formula": "(rank(correlation(((high * 0.876703) + (close * (1 - 0.876703))), adv30, 9.61331))^rank(correlation(ts_rank(((high + low) / 2), 3.70596), ts_rank(volume, 10.1595), 7.11408)))",
        "dependencies": ["high", "close", "low", "volume", "adv20"],
        "window": 10,
        "description": "加权价格与成交量相关性及中间价成交量时序相关性的幂运算",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha086": {
        "formula": "((ts_rank(correlation(close, sum(adv20, 14.7444), 6.00049), 20.4195) < rank(((open + close) - (vwap + open)))) * -1)",
        "dependencies": ["close", "open", "vwap", "adv20"],
        "window": 20,
        "description": "收盘价与成交量相关性时序排名与价格偏离的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha087": {
        "formula": "(max(rank(decay_linear(delta(((close * 0.369701) + (vwap * (1 - 0.369701))), 1.91233), 2.65461)), ts_rank(decay_linear(abs(correlation(IndNeutralize(adv81, IndClass.industry), close, 13.4132)), 4.89768), 14.4535)) * -1)",
        "dependencies": ["close", "vwap", "adv20"],
        "window": 14,
        "description": "加权价格变化与行业中性化成交量收盘价相关性绝对值的最大值",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha088": {
        "formula": "min(rank(decay_linear(((rank(open) + rank(low)) - (rank(high) + rank(close))), 8.06882)), ts_rank(decay_linear(correlation(ts_rank(close, 8.44728), ts_rank(adv60, 20.6966), 8.01687), 6.65053), 2.61957))",
        "dependencies": ["open", "low", "high", "close", "adv20"],
        "window": 21,
        "description": "价格排名差异与收盘价成交量时序相关性的最小值",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha089": {
        "formula": "(ts_rank(decay_linear(correlation(((low * 0.967285) + (low * (1 - 0.967285))), adv10, 6.94279), 5.51607), 3.79744) - ts_rank(decay_linear(delta(IndNeutralize(vwap, IndClass.industry), 3.48158), 10.1466), 15.3012))",
        "dependencies": ["low", "vwap", "adv20"],
        "window": 15,
        "description": "最低价与成交量相关性减去行业中性化VWAP变化的时序排名差",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha090": {
        "formula": "((rank((close - ts_max(close, 4.66719)))^ts_rank(correlation(IndNeutralize(adv40, IndClass.subindustry), low, 5.38375), 3.21856)) * -1)",
        "dependencies": ["close", "low", "adv20"],
        "window": 5,
        "description": "收盘价相对位置与行业中性化成交量最低价相关性的幂运算",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha091": {
        "formula": "((ts_rank(decay_linear(decay_linear(correlation(IndNeutralize(close, IndClass.industry), volume, 9.74928), 16.398), 3.83219), 4.8667) - rank(decay_linear(correlation(vwap, adv30, 4.01303), 2.6809))) * -1)",
        "dependencies": ["close", "volume", "vwap", "adv20"],
        "window": 16,
        "description": "行业中性化收盘价成交量双重衰减相关性减去VWAP成交量相关性",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha092": {
        "formula": "min(ts_rank(decay_linear(((((high + low) / 2) + close) < (low + open)), 14.7221), 18.8683), ts_rank(decay_linear(correlation(rank(low), rank(adv30), 7.58555), 6.94024), 6.80584))",
        "dependencies": ["high", "low", "close", "open", "adv20"],
        "window": 19,
        "description": "价格条件判断与最低价成交量排名相关性的最小值",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha093": {
        "formula": "(ts_rank(decay_linear(correlation(IndNeutralize(vwap, IndClass.industry), adv81, 17.4193), 19.848), 7.54455) / rank(decay_linear(delta(((close * 0.524434) + (vwap * (1 - 0.524434))), 2.77377), 16.2664)))",
        "dependencies": ["vwap", "close", "adv20"],
        "window": 20,
        "description": "行业中性化VWAP成交量相关性除以加权价格变化的比率",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha094": {
        "formula": "((rank((vwap - ts_min(vwap, 11.5783)))^ts_rank(correlation(ts_rank(vwap, 19.6462), ts_rank(adv60, 4.02992), 18.0926), 2.70756)) * -1)",
        "dependencies": ["vwap", "adv20"],
        "window": 20,
        "description": "VWAP相对位置与VWAP成交量时序相关性的幂运算",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha095": {
        "formula": "(rank((open - ts_min(open, 12.4105))) < ts_rank((rank(correlation(sum(((high + low) / 2), 19.1351), sum(adv40, 19.1351), 12.8742))^5), 11.7584))",
        "dependencies": ["open", "high", "low", "adv20"],
        "window": 19,
        "description": "开盘价相对位置与中间价成交量相关性五次幂的比较",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha096": {
        "formula": "(max(ts_rank(decay_linear(correlation(rank(vwap), rank(volume), 3.83878), 4.16783), 8.38151), ts_rank(decay_linear(ts_argmax(correlation(ts_rank(close, 7.45404), ts_rank(adv60, 4.13242), 3.65459), 12.6556), 14.0365), 13.4143)) * -1)",
        "dependencies": ["vwap", "volume", "close", "adv20"],
        "window": 14,
        "description": "VWAP成交量排名相关性与收盘价成交量时序相关性最大值位置的最大值",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha097": {
        "formula": "((rank(decay_linear(delta(IndNeutralize(((low * 0.721001) + (vwap * (1 - 0.721001))), IndClass.industry), 3.3705), 20.4523)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(low, 7.87871), ts_rank(adv60, 17.255), 4.97547), 18.5925), 15.7152), 6.71659)) * -1)",
        "dependencies": ["low", "vwap", "adv20"],
        "window": 20,
        "description": "行业中性化加权价格变化减去最低价成交量多重时序相关性",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha098": {
        "formula": "(rank(decay_linear(correlation(vwap, sum(adv5, 26.4719), 4.58418), 7.18088)) - rank(decay_linear(ts_rank(ts_argmin(correlation(rank(open), rank(adv15), 20.8187), 8.62571), 6.95668), 8.07206)))",
        "dependencies": ["vwap", "open", "adv20"],
        "window": 26,
        "description": "VWAP成交量相关性减去开盘价成交量相关性最小值位置的排名差",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha099": {
        "formula": "((rank(correlation(sum(((high + low) / 2), 19.8975), sum(adv60, 19.8975), 8.8136)) < rank(correlation(low, volume, 6.28259))) * -1)",
        "dependencies": ["high", "low", "volume", "adv20"],
        "window": 20,
        "description": "中间价成交量累积相关性与最低价成交量相关性的比较",
        "category": "volume",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha100": {
        "formula": "(0 - (1 * (((1.5 * scale(IndNeutralize(IndNeutralize(rank(((((close - low) - (high - close)) / (high - low)) * volume)), IndClass.subindustry), IndClass.subindustry))) - scale(IndNeutralize((correlation(close, rank(adv20), 5) - rank(vwap)), IndClass.sector))) * (volume / adv20))))",
        "dependencies": ["close", "high", "low", "volume", "vwap", "adv20"],
        "window": 5,
        "description": "复杂的多重行业中性化价格动量与成交量相关性的综合因子",
        "category": "momentum",
        "frequency": "daily",
        "neutralize": True
    },
    
    "alpha101": {
        "formula": "((close - open) / ((high - low) + .001))",
        "dependencies": ["close", "open", "high", "low"],
        "window": 1,
        "description": "标准化的开收盘价变化率因子",
        "category": "price",
        "frequency": "daily",
        "neutralize": True
    }
}

# 因子分类
FACTOR_CATEGORIES = {
    "momentum": "动量因子",
    "volume": "成交量因子", 
    "price": "价格因子",
    "volatility": "波动率因子",
    "correlation": "相关性因子",
    "technical": "技术指标因子"
}

# 数据依赖项映射
DATA_DEPENDENCIES = {
    "close": "收盘价",
    "open": "开盘价", 
    "high": "最高价",
    "low": "最低价",
    "volume": "成交量",
    "vwap": "成交量加权平均价",
    "returns": "收益率",
    "adv20": "20日平均成交量"
}

# 默认参数
DEFAULT_PARAMS = {
    "neutralize": True,  # 是否进行行业中性化
    "standardize": True,  # 是否标准化
    "winsorize": True,   # 是否去极值
    "winsorize_limits": (0.025, 0.975),  # 去极值的分位数
    "min_periods": 20,   # 最小计算周期
    "parallel": True     # 是否并行计算
}

def get_factor_config(factor_id):
    """
    获取指定因子的配置信息
    
    Parameters:
    -----------
    factor_id : str
        因子ID，如'alpha001'
        
    Returns:
    --------
    dict
        因子配置信息
    """
    if factor_id not in ALPHA_CONFIG:
        raise ValueError(f"Unknown factor ID: {factor_id}")
    
    config = ALPHA_CONFIG[factor_id].copy()
    # 添加默认参数
    for key, value in DEFAULT_PARAMS.items():
        if key not in config:
            config[key] = value
    
    return config

def list_factors_by_category(category=None):
    """
    按类别列出因子
    
    Parameters:
    -----------
    category : str, optional
        因子类别
        
    Returns:
    --------
    list
        因子ID列表
    """
    if category is None:
        return list(ALPHA_CONFIG.keys())
    
    return [factor_id for factor_id, config in ALPHA_CONFIG.items() 
            if config.get('category') == category]

def get_factor_dependencies(factor_id):
    """
    获取因子的数据依赖项
    
    Parameters:
    -----------
    factor_id : str
        因子ID
        
    Returns:
    --------
    list
        依赖的数据字段列表
    """
    config = get_factor_config(factor_id)
    return config['dependencies']

def validate_factor_config(factor_id):
    """
    验证因子配置的完整性
    
    Parameters:
    -----------
    factor_id : str
        因子ID
        
    Returns:
    --------
    bool
        配置是否有效
    """
    try:
        config = get_factor_config(factor_id)
        required_fields = ['formula', 'dependencies', 'window', 'description', 'category']
        
        for field in required_fields:
            if field not in config:
                return False
        
        # 验证依赖项是否有效
        for dep in config['dependencies']:
            if dep not in DATA_DEPENDENCIES:
                return False
        
        return True
    except:
        return False